# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from fastapi import APIRouter, Request, Depends
from hypertext import R, response_json, PagingResult
from apps.api.schemas.agent.robot import smarter_schema as schema
from apps.api.service.agent.robot.smarter_service import RobotSmarterService

router = APIRouter(prefix="/smarter", tags=["智能体管理接口"])


@router.get("/lists", summary="智能体列表", response_model=R[PagingResult[schema.RobotSmarterListVo]])
@response_json
async def lists(request: Request, params: schema.RobotSmarterSearchIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.lists(params, user_id)


@router.get("/detail", summary="智能体详情", response_model=R[schema.RobotSmarterDetailVo])
@response_json
async def detail(request: Request, params: schema.RobotSmarterDetailIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.detail(params.code, user_id)


@router.post("/add", summary="智能体创建", response_model=R)
@response_json
async def add(request: Request, params: schema.RobotSmarterAddIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.add(params, user_id)


@router.post("/edit", summary="智能体编辑", response_model=R)
@response_json
async def edit(request: Request, params: schema.RobotSmarterEditIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.edit(params, user_id)


@router.post("/delete", summary="智能体删除", response_model=R)
@response_json
async def delete(request: Request, params: schema.RobotSmarterCodeIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.delete(params.code, user_id)


@router.post("/clone", summary="智能体克隆", response_model=R)
@response_json
async def clone(request: Request, params: schema.RobotSmarterCodeIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.clone(params.code, user_id)


@router.post("/square", summary="智能体公开", response_model=R)
@response_json
async def square(request: Request, params: schema.RobotSmarterCodeIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.square(params.code, user_id)


@router.post("/collect", summary="智能体收藏", response_model=R)
@response_json
async def collect(request: Request, params: schema.RobotSmarterCodeIn):
    user_id: int = int(request.state.user_id)
    return await RobotSmarterService.collect(params.code, user_id)
